package org.graduation.rbac.service;

import com.baomidou.mybatisplus.extension.service.IService;
import org.graduation.model.common.RBAC.Permissions;
import org.graduation.model.common.RBAC.Roles;
import org.graduation.model.common.RBAC.UserPermission;
import org.graduation.model.common.ResponseResult;

import java.util.Set;

public interface UserPermissionService extends IService<UserPermission> {
    /**
     * owner任命uid为pId项目的管理员
     *
     * @param pId   项目Id
     * @param owner 项目拥有者
     * @param uid   被任命的用户
     * @return
     */
    ResponseResult designateAdmin(Long pId, Integer owner, Integer uid);

    /**
     * owner撤销pId项目的adminUid管理员
     *
     * @param pId      项目Id
     * @param owner    项目拥有者
     * @param adminUid 管理员Id
     * @return
     */
    ResponseResult revokeAdmin(Long pId, Integer owner, Integer adminUid);

    /**
     * 获取uid关于pId项目的所有权限集合
     *
     * @param pId 项目Id
     * @param uid 用户Id
     * @return
     */
    Set<Permissions> getUserAllPermissions(Long pId, Integer uid);

    /**
     * 验证某个uid用户关于pId项目是否拥有permission权限
     *
     * @param pId         项目Id
     * @param uid         用户Id
     * @param permissions 权限枚举
     * @return
     */
    ResponseResult checkPermission(Long pId, Integer uid, Permissions permissions);

    /**
     * 为uid分配某个角色
     *
     * @param pId
     * @param uid
     * @param role
     * @return
     */
    ResponseResult assignRole(Long pId, Integer uid, Roles role);

    /**
     * 为uid撤销某个角色
     *
     * @param pId
     * @param uid
     * @param role
     * @return
     */
    ResponseResult revokeRoles(Long pId, Integer uid, Roles role);
}
